package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsAdmin;
import com.qf.pojo.DtsGoods;
import com.qf.service.GoodsService;
import com.qf.util.AuthSupport;
import com.qf.util.ResponseUtil;
import com.qf.vo.CategorySellVo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * projectName: wokepase1
 *
 * @author: 强力
 * time: 2021/9/15 8:33
 * description:
 */
@RestController
@RequestMapping("/goods")
@CrossOrigin("*")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("list")
    public Object goodlist(Integer page,Integer limit,String goodsSn,String name,String sort,String order){
        IPage<DtsGoods> goodsIPage=goodsService.findByBage(page,limit,goodsSn,name,sort,order);
    //封装返回数据
        Map<String,Object> data=new HashMap<>();
        data.put("total",goodsIPage.getTotal());
        data.put("items",goodsIPage.getRecords());
        return ResponseUtil.ok(data);

    }

    @RequestMapping("/create")
    public Object create(@RequestBody DtsGoods goods){

        goodsService.insert(goods);
        return ResponseUtil.ok(goods);

    }
    @RequestMapping("/catAndBrand")
    public Object catAndBrand(){

        return null;
    }
}
